﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZkSurvey.Common.SurveyMgr;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;
using System.Data;

namespace ZkSurvey.DAL.SurveyMgr
{
    public class DicQuestionTypeDa
    {
        public static List<DicQuestionType> GetDicQuestionTypeList()
        {
            Database db = DBHelper.GetDatabase();
            List<DicQuestionType> types = new List<DicQuestionType>();

            using (IDataReader dataReader = db.ExecuteReader("Usp_GetDicQuestionTypeList"))
            {
                while (dataReader.Read())
                {
                    DicQuestionType type = new DicQuestionType();
                    type.Id = dataReader.GetInt32(0);
                    type.Title = dataReader.GetString(1);
                    if (!dataReader.IsDBNull(2))
                        type.Description = dataReader.GetString(2);
                    type.Sort = dataReader.GetInt32(3);
                    type.IsValid = dataReader.GetBoolean(4);

                    types.Add(type);
                }
            }
            return types;
        }
    }
}
